package com.xinruke.hostels.support.common;


/**
 * @author Chenry
 * @ClassName ImgSuffix
 * @date：2019/6/22
 * @version: V1.0.0
 * @description：图片格式常量定义
 */
public class ImgSuffix {
    //图片后缀
    static String imgeArray[] =
            {"bmp", "dib", "gif", "jfif", "jpe", "jpeg", "jpg", "png", "tif", "tiff", "ico"};
    //文件后缀
	/*static String fileArray [] = 
			{"doc","html","bak","zip","pdf","xls","txt","wps","rtf","rar","arj"}; */

    /**
     * 根据后缀名校验（String imgeArray []）
     *
     * @param imgName
     * @return boolean
     * @throws
     */
    public static boolean checkImgSuffix(String imgName) {
        boolean flag = true;
        for (int i = 0; i < imgeArray.length; i++) {
            String imgSuffix = imgName.substring(imgName.lastIndexOf(".") + 1);
            if (imgeArray[i].equals(imgSuffix.toLowerCase())) {
                flag = true;
                break;
            } else {
                flag = false;
            }
        }
        return flag;

    }

    /**
     * 测试方法
     */
    public static void main(String[] args) {
        //boolean chackSuffix = ChackFileSuffix("qwqwqw.doc");
        //System.err.println(chackSuffix);
    }

}
